-- Viral Resistance - T-Engine 4 Module
-- Copyright (C) 2010 Mikolai Fajer
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- Mikolai Fajer "yufra"
-- mfajer@gmail.com

newChat{ id="first",
	text = [[#LIGHT_GREEN#The noises die down as you draw close.]],
	answers = {
		{[["I need to fix the conduits!"]],
			jump = "greeting",
			cond=function(npc, player)
				return player:isQuestStatus("power_loss", engine.Quest.PENDING, "find_broken_conduit")
			end,
		},
		{"#LIGHT_BLUE#Walk away."},
	}
}

newChat{ id="greeting",
	text = [[#WHITE#"You don't sound like one of those crazies, who are you?"]],
	answers = {
		{([["I am Corporal %s, who are you?"]]):format(game.player.name),
			jump = "intro",
		},
	}
}

newChat{ id = "intro",
	text = [["The name is Dan, and I keep this place running."  ADD MORE LATER]],
	answers = {
		{[["Let's go then."]],
			action=function(npc, player)
				local door = game.level.map(npc.x, npc.y, engine.Map.TERRAIN)
				-- Remove the noise object
				game.level.map:removeObject(npc.x, npc.y, 1)
				-- Replace the door with an open door
				local replacement = game.zone:makeEntityByName(game.level, 'terrain', door.door_unlocked)
				replacement = game.zone:makeEntityByName(game.level, 'terrain', replacement.door_opened)
				game.zone:addEntity(game.level, replacement, "terrain", npc.x, npc.y)
				player:isQuestStatus("power_loss", engine.Quest.PENDING, "fix_broken_conduits")
			end,
		},
	}
}

return "first"